package com.rpinfo.editalog.util;

import com.rpinfo.editalog.config.Cfg;
import com.rpinfo.editalog.config.CfgPropUtil;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author camilo
 */
public class ConJdbcUtil {

  public static Connection getConexao() throws SQLException {
    try {
      Class.forName("org.postgresql.Driver");
      CfgPropUtil propUt = new CfgPropUtil();
      Cfg prop = propUt.getCfgProp();
      return DriverManager.getConnection(
              "jdbc:postgresql://"
              + prop.getIp()
              + ":" + prop.getPorta()
              + "/" + prop.getNomeBd(),
              prop.getUser(),
              prop.getPassword());
      /*"jdbc:jtds:sqlserver://127.0.0.1:1433/ControleFinanceiro;"
       *+ "instance=SQLEXPRESS;user=sa;password=senha");
       */
    } catch (ClassNotFoundException e) {
      throw new SQLException(e.getMessage());
    }
  }
}
